<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8 no-js"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="ie9 no-js"> <![endif]-->
<!--[if !IE]><!-->
<html lang="en" class="no-js">
<!--<![endif]-->
<!-- BEGIN HEAD -->
<head>
<meta charset="utf-8" />
<title>门店管理 - 门店出库</title>
<?php include($this->c['_homes']['_viewsHome'].'/_global/_head.php');?>
<link rel="stylesheet" type="text/css" href="/style/assets/plugins/bootstrap-datetimepicker/css/datetimepicker.css" />
</head>
<!-- BEGIN BODY -->
<body class="page-header-fixed page-sidebar-fixed">
<!-- BEGIN HEADER -->
<?php include($this->c['_homes']['_viewsHome'].'/_global/head.php');?>
<!-- END HEADER -->
<div class="clearfix"></div>
<!-- BEGIN CONTAINER -->
<div class="page-container" > 
  <!-- BEGIN HORIZONTAL MENU PAGE SIDEBAR1 -->
  <?php include($this->c['_homes']['_viewsHome'].'/_global/menu.php');?>
  <!-- END BEGIN HORIZONTAL MENU PAGE SIDEBAR --> 
  <!-- BEGIN PAGE -->
  <div class="page-content"> 
    <!-- BEGIN PAGE HEADER-->
    <div class="row">
      <div class="col-md-12"> 
        <!-- BEGIN PAGE TITLE & BREADCRUMB-->
        <h3 class="page-title"> 门店出库</h3>
        <ul class="page-breadcrumb breadcrumb">      
         
          <li> <i class="icon-home"></i> <a href="/manage">后台</a> <i class="icon-angle-right"></i> </li>
          <li> 门店管理 <i class="icon-angle-right"></i> </li>
          <li>门店出库</li>
        </ul>
        <!-- END PAGE TITLE & BREADCRUMB--> 
      </div>
    </div>
    <!-- END PAGE HEADER--> 
    <!-- BEGIN PAGE CONTENT-->
    <div class="row">
      <div class="col-md-12">
        <div class="portlet box">
          <div class="booking-search">
            <form action="" role="form" method="get">
              <div class="row form-group">              
                <div class="col-md-3">                  
                  <div class="input-cont">
                    <input class="form-control" name="keyword" placeholder="订单号/ID/商品ID/商品名称" value="<?=$_GET['keyword'];?>" type="text">
                  </div>
                </div>
              <div class="col-md-2">
                  <select class="form-control" name="store_id" id="_store_id">
                      <option value="">门店</option>
                      <?php
                      if($this->store){
                          foreach($this->store as $k=> $r){
                              if(isset($this->data['para']['store_id']) && $r['store_id']==$this->data['para']['store_id']) $slk = ' selected';
                              else $slk = '';
                              $newstore[$r['store_id']] = $r['name'];
                              ?>
                              <option value="<?=$r['store_id'];?>"<?=$slk;?>><?=$r['name'];?></option>
                              <?
                          }
                      }
                      ?>
                  </select>
              </div>
                 <div class="col-md-3">
                    <div class="input-group date form_datetime" data-date="<?=date("Y-m-d\TH:i\Z");?>">
                            <input type="text" size="16" name="start_time" placeholder="选择开始时间" id="start_time" value="<?=$_GET['start_time']?>" readonly class="form-control">
                            <span class="input-group-btn">
                            <button class="btn default date-reset" type="button"><i class="icon-remove"></i></button>
                            </span> <span class="input-group-btn">
                            <button class="btn default date-set" type="button"><i class="icon-calendar"></i></button>
                            </span> </div>
                  </div>
                  <div class="col-md-3">
                    <div class="input-group date form_datetime" data-date="<?=date("Y-m-d\TH:i\Z");?>">
                            <input type="text" size="16" name="end_time" placeholder="选择结束时间" id="end_time" value="<?=$_GET['end_time']?>" readonly class="form-control">
                            <span class="input-group-btn">
                            <button class="btn default date-reset" type="button"><i class="icon-remove"></i></button>
                            </span> <span class="input-group-btn">
                            <button class="btn default date-set" type="button"><i class="icon-calendar"></i></button>
                            </span> </div>
                  </div> 
               </div>  
               <div class="row form-group">                
                <div class="col-md-1"><input type="submit" class="btn blue btn-block" value="搜 索"></div>
                  <div class="col-md-1">
                  <input type="button" onclick="javascript:window.location.href='/store/breakage'" class="btn blue btn-block" value="报损记录">
                </div>
              </div>
            </form>
          </div>
        </div>
      </div>
    </div>
    <div class="row">
      <div class="col-md-12"> 
        <!-- BEGIN SAMPLE TABLE PORTLET-->                  
        <div class="portlet box blue">
          <div class="portlet-title">
            <div class="caption"><i class="icon-list"></i>列表(<?=$this->data['count'];?>)</div>
          
		<div class="actions">
            
            </div>
          </div>
        
          <div class="portlet-body">
            <div class="table-scrollable">
             <table class="table table-striped table-bordered table-hover dataTable">
              <thead>
                <tr>
                 <th><input type="checkbox" id="_checkboxall" value="1"></th>
                    <th>订单ID</th>
                    <th>订单号/下单时间</th>
                    <th>买家昵称</th>
                    <th>收货人</th>
                    <th>电话</th>
                    <th>付款状态</th>
                    <th>发货状态</th>
                    <th>退货状态</th>
                    <th>退款状态</th>
                    <th>销售类型</th>
                    <th>仓库</th>
                    <th>商品ID</th>
                    <th>商品名称</th>
                    <th>门店</th>
                    <th>购买数量</th>
                    <th>零售价</th>
                    <th>市场价</th>
                    <th>进货价</th>
                </tr>
              </thead>
             <tbody>
              <?php
            			if($this->data['data'])
            			{
            				foreach($this->data['data'] as $k=> $r){										
            					
            					

            			?>
                <tr>
                 <td><input type="checkbox" class="_checkboxs" name="order_id[]" value="<?=$r['order_id'];?>"></td>
                    <td><?=$r['order_id'];?></td>
                  <td><strong><?=$r['order_sn'];?></strong><br>
                  <?=date("Y-m-d H:i",$r['add_time']);?></td>
                  <td>[<?=$r['uid'];?>] <?=stripslashes($this->data['user'][$r['uid']]['realname']);?></td>
                </td>
                  <td><?=$r['consignee'];?></td>
                    <td><?=$r['mobile'];?></td>
                  <td>
                  <?=$r['pay_status'];?>
                  </td>
                  <td>
                  <?=$r['shipping_status'];?>
                  </td>
                  <td>
                  <?=$this->c['stat']['order_show']['return_goods_status'][$r['return_goods_status']];?>
                  </td>
                  <td>
                  <?=$this->c['stat']['order_show']['refund_status'][$r['refund_status']];?>
                  </td>
                  <td>
                   <?=$this->c['stat']['order']['sell_type'][$r['sell_type']];?>
                   </td>
                   <td>
                        <?php
                          if($r['warehouse_type']==1) echo "本地仓";
                          elseif($r['warehouse_type']==2) echo "保税仓";
                          elseif($r['warehouse_type']==3) echo "海外仓";
                        ?>
                   </td>
                   <td><?=$r['goods_id']; ?></td>
                    <td><?=$r['goods_name']; ?> </td>
                    <td><?=$newstore[$r['store_id']];?></td> 
                    <td><?=$r['goods_number']; ?></td>
                    <td><?=$r['goods_price'];?></td>
                    <td><?=$r['market_price'];?></td>
                    <td><?=$r['purchase_price'];?></td>
                   </tr>
                        <?php
        					}
        				   }
        				?>
				 </tbody>                                
            </table>
            </div>
          </div>
        </div>
        <?php
		if($this->data['maxpage'] > 1){
		?>
        <div>
          <ul class="pagination">
            <?
			$pquery="?";		
			if($this->data['para']){			
				foreach($this->data['para'] as $k=>$r){				
					$pquery.=$k."=".$r."&";
					$form_hidden .= '<input type="hidden" name="'.$k.'" value="'.$r.'">';
				}			
			}
			
			if($this->data['page'] > 1) echo '<li><a href="'.$pquery.'page='.($this->data['page']-1).'"><i class="icon-angle-left"></i></a></li>';
			for($i = $this->data['spage']['ps']; $i<=$this->data['spage']['pe']; $i++){
			if($i == $this->data['page']) echo '<li class="disabled"><a href="javascript:void(0);">'.$i.'</a></li>';
			else echo '<li><a href="'.$pquery.'page='.$i.'">'.$i.'</a></li>';
			}
			
			if($this->data['page'] < $this->data['maxpage']) echo '<li><a href="'.$pquery.'page='.($this->data['page']+1).'"><i class="icon-angle-right"></i></a></li>';
			?>
          </ul>
          <div class="jumppage">
          <form method="get" action="">
          <?=$form_hidden;?>
          页码：<?=$this->data['page'];?>/<?=$this->data['maxpage'];?>
          跳到 <input type="text" name="page" class="value"> 页          
          <input type="submit" value="GO" class="sub">
          </form>
          </div>
        </div>
        <?
 		}
?>
        <!-- END SAMPLE TABLE PORTLET--> 
      </div>
    </div>
    <!-- END PAGE CONTENT--> 
  </div>
  <!-- END PAGE --> 
</div>
<!-- END CONTAINER -->
<form method="post" id="_batch" action="/order/exportBatchs">
  <input type="hidden" name="order_ids" id="_batch_dataid" value="">
</form>
<?php include($this->c['_homes']['_viewsHome'].'/_global/_footer.php');?>
<script type="text/javascript" src="/style/assets/plugins/bootstrap-datetimepicker/js/bootstrap-datetimepicker.js"></script> 
<script type="text/javascript" src="/style/assets/plugins/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js"></script>
<script>
jQuery(document).ready(function() {    
   App.init();
   handleDatetimePicker();
   if (jQuery().datepicker) {
       $('.date-picker').datepicker({
           rtl: App.isRTL(),
           autoclose: true
       });
       $('body').removeClass("modal-open"); // fix bug when inline picker is used in modal
     }
   jQuery('#_checkboxall').change(function () {
	  var checked = jQuery(this).is(":checked");
	  jQuery("._checkboxs").each(function () {
		  if (checked) {
			  $(this).attr("checked", true);
		  } else {
			  $(this).attr("checked", false);
		  }
		  $(this).parents('tr').toggleClass("active");
	  });
	  jQuery.uniform.update("._checkboxs");
  });
  
  $("._checkboxs").change(function() {
	  var checked = jQuery(this).is(":checked");
	  if (!checked) {			
		  $(this).attr("checked", false);
		  $(this).parents('tr').removeClass("active");
		  $("#_checkboxall").attr("checked",false);
		  jQuery.uniform.update("#_checkboxall");
	  }
  });
});

var handleDatetimePicker = function () {
	  $(".form_datetime").datetimepicker({
	    language:'zh-CN',
	    autoclose: true,
	    format: "yyyy-mm-dd hh:ii"
	  }); 
	  $('body').removeClass("modal-open"); // fix bug when inline picker is used in modal
	}
function _export_action(){
	$("#_dataid").prop("value",_dataid);
	$("#_frm").submit();
}

function _batch(){
	var _ids = '';
	
	$("._checkboxs").each(function () {
		if( $(this).attr("checked")  ) {
			if(_ids!="") _ids +=',';
			_ids += $(this).val();
		}
	});
	if(_ids!=""){
		$("#_batch_dataid").prop("value",_ids);
		cm = confirm("您确定要导出这些订单吗？");
		if(cm){
				$("#_batch").submit();
		}
	}
	else alert("至少选择一个订单");
}

function _shipping(){
	var _idss = '';
	
	$("._checkboxs").each(function () {
		if( $(this).attr("checked")  ) {
			if(_idss!="") _idss +=',';
			_idss += $(this).val();
		}
	});
	if(_idss!=""){
		//$("#_orderIds").prop("value",_idss);
		cm = confirm("您确定要设置这些订单为发货中吗？");
		if(cm){
			
			$.post("ajax",
	  	      {
	  	        "act":"shipping_status",
	  	        "order_ids":_idss,
	  	        "mr":Math.random()
	  	      },
	  	      function(json){
	  	        if(json.code==200)
	  	        {
	  	          swal("保存成功",false,"success");
		  	        window.location.reload();    

	  	        }
	  	        else{
	  	          swal(json.msg,"错误代码["+json.code+"]","error");
	  	        }

	  	      },"json"); 
		}
	}
	else alert("至少选择一个订单");
}
</script> 
<!-- END JAVASCRIPTS -->
</body>
<!-- END BODY -->
</html>